import { createAction } from '@reduxjs/toolkit'

// 本文件主要用来处理交换代币，是uniswap的核心功能

export enum Field {
  INPUT = 'INPUT',
  OUTPUT = 'OUTPUT'
}

// 选择代币
export const selectCurrency = createAction<{ field: Field; currencyId: string }>( 'swap/selectCurrency' )
// 切换代币
export const switchCurrencies = createAction<void>( 'swap/switchCurrencies' )
//  输入类型
export const typeInput = createAction<{ field: Field; typedValue: string }>('swap/typeInput')
// 替换交换状态
export const replaceSwapState = createAction<{
  field: Field
  typedValue: string
  inputCurrencyId?: string
  outputCurrencyId?: string
  recipient: string | null
}>( 'swap/replaceSwapState' )
// 设置交易接收
export const setRecipient = createAction<{ recipient: string | null }>('swap/setRecipient')
